package com.ysd.entity;

import java.sql.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Entity
@Table(name="permission")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Permission {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private String Permissionid;
	private String Permissionvalue;
	private String Permissionmodule;
	private String Permissionname;
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date Permissionlastupdatetime;
	@JsonIgnoreProperties("plist")
	@ManyToMany(fetch=FetchType.EAGER,cascade=CascadeType.ALL) //多对多关系
	@JoinTable(name="rolepermission",
			joinColumns={@JoinColumn(name="permissionid")}, //被维护方外键的对应关系
			inverseJoinColumns={@JoinColumn(name="rid")})
	@NotFound(action=NotFoundAction.IGNORE)//防止乙方对应时无数据报错
	private List<Roles> rlist;
	
}
